using System;
using System.IO;

namespace Coding4Fun.BoxingBots.Common
{
	public class RobotStatePacket : GamePacket
	{
		public CalculatedSensorData SensorData { get; set; }
		public bool PunchDetected { get; set; }
		public bool MovementOverride { get; set; }
		public bool LockSkeleton { get; set; }

		public override void ReadPacket(BinaryReader br)
		{
			SensorData = SensorData.Read(br);
			PunchDetected = br.ReadBoolean();
			MovementOverride = br.ReadBoolean();
			LockSkeleton = br.ReadBoolean();
		}

		public override void WritePacket(BinaryWriter bw)
		{
			SensorData.Write(bw);
			bw.Write(PunchDetected);
			bw.Write(MovementOverride);
			bw.Write(LockSkeleton);
		}

		public override string ToString()
		{
			return string.Format(
								"SensorData: {0}" + Environment.NewLine +
								"PunchDetected: {1}" + Environment.NewLine +
								"MovementOverride: {2}" + Environment.NewLine +
								"LockSkeleton: {3}",
								SensorData, PunchDetected, MovementOverride, LockSkeleton);
		}
	}
}